﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace RssNewsFeeder.Commands
{
    public class Command:ICommand
    {
        private Action<object> _execute;
        private Predicate<object> _canExecute;

        public Command(Action<object> execute, Predicate<object> canExecute)
        {
            _execute = execute;
            _canExecute = canExecute;
        }

        public event EventHandler CanExecuteChanged;
        bool ICommand.CanExecute(object parameter)
        {
            return parameter == null ? true : _canExecute(parameter);
        }
        
        void ICommand.Execute(object parameter)
        {
            _execute(parameter);
        }
                
    }
}
